package com.liu.webManagent.controller;

import com.liu.common.commons.R;
import com.liu.common.enums.HttpStatus;
import com.liu.service.entity.SysUser;
import com.liu.service.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author : liuxinghong
 * @Description : 登录调用相关接口
 * @date: 2020/11/30 18:54
 **/
@Api(tags = {"用户登录"})
@RestController
@Slf4j
@RequestMapping("/login")
public class LoginController {

    @Resource
    private ISysUserService sysUserService;

    @ApiOperation(value = "新增用户表")
    @GetMapping("/getUserByUserName")
    public R getUserByUserName(@RequestParam("userName") String userName){
        try {
            return R.ok(sysUserService.getUserByUserName(userName));
        } catch (Exception e) {
            log.error(e.getMessage(), e);
            return R.failed(false, HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}
